home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 5608 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.4 KB  |  60 lines

  1. Path: qualcomm.com!usenet
  2. From: nabbasi@qualcomm.com (Nasser Abbasi)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: generic paramter to template question
  5. Date: 5 Feb 1996 21:53:57 GMT
  6. Organization: QUALCOMM
  7. Message-ID: <4f5u9l$3oh@qualcomm.com>
  8. References: <4eumei$j82@qualcomm.com> <DMBEA7.ID6@news.arco.com>
  9. NNTP-Posting-Host: nabbasi.qualcomm.com
  10. Mime-Version: 1.0
  11. X-Newsreader: WinVN 0.93.14
  12.  
  13. In article <DMBEA7.ID6@news.arco.com>, lasbfl says...
  14. >
  15. >nabbasi@qualcomm.com (Nasser Abbasi) wrote:
  16. >>hi,
  17. >>
  18. >>How can one give a template a parameter that is a value of generic 
  19. type?
  20. >>
  21. >>A template can take as paramter as a type, and also it can take a 
  22. >>parameter that is a variable of known type as in:
  23. >>
  24. >>template<class T,int item> class foo{..}
  25. >>
  26. >>but in the above the type of "item" is not generic. is there a way 
  27. >>to pass "item" above but let the user have its type as generic also (as 
  28. >>with T) ? 
  29. >>
  30. >>thanks
  31. >>Nasser
  32. >>
  33. >
  34. >You are allowed any number of parameters of unknown type,ie:
  35. >template<class T, class U, class V> class food {...}
  36. >-Brian :-)
  37. >
  38.  
  39. I think I did not make my question clear.
  40.  
  41. In the above, T,U,V are TYPES. the excat TYPE of which is determined 
  42. when the template is instaniated.
  43.  
  44. What I want is to pass a parameter to a template, and have also the type 
  45. of that parameter be generic.
  46.  
  47. i.e. if this were allowed, I'd like to do this:
  48.  
  49. template<class T,<class U>item> 
  50. class foo
  51. {
  52. T obj;
  53. U obj2 = item;
  54. }
  55.  
  56.  
  57. thanks
  58. Nasser
  59.  
  60.